#ifndef __RADIO_CONFIG_H__
#define __RADIO_CONFIG_H__

#include "gd32f30x.h"

#define CHUANZHOU_PROTOCOL 0
#define PROCS_PROTOCOL     1
/*发射端和接收端只能二选一*/
#define RADIO_MODE_IS_TRANSMITTING_END  0 /* 发射端*/
#define RADIO_MODE_IS_RECEIVING_END     1 /* 接收端*/

#define RADIO_RX_AND_TX   1 /*0:发送方只发送，接收方只接收；1：发送方发送和接收，接收方接收和发送*/

#define RADIO_TX_DATA_BUFF_NUMBER 30

#define RADIO_RX_DATA_BUF         32/*无线接收数据buf长度*/

#if (PROCS_PROTOCOL == 1)
typedef union radio_rx_data_buf{
    uint8_t buf[32];
    struct{
        uint8_t cmd;
        uint8_t key0;
        uint8_t key1;
        uint8_t reverse_0;
        uint8_t reverse_1;
        uint8_t reverse_2;
        uint8_t reverse_3;
        uint8_t reverse_4;

        uint16_t reverse_5;
		uint16_t bat_voltage;
        
        uint32_t remaining_shutdown_time;
        uint32_t radio_tx_counter;	  
    }data;
}radio_rx_data_t;
    #if (RADIO_RX_AND_TX == 1)
    typedef struct motor_data{
        int16_t speed;
        uint8_t dc_voltage;
        int8_t  dc_current;
        uint8_t control_status;
        uint8_t fault_code;
    }motor_data_t;
    typedef union radio_tx_data_buf{
        uint8_t buf[RADIO_TX_DATA_BUFF_NUMBER];
        struct{
            uint8_t reserve_0;
            uint8_t bms_voltage;
            int8_t  bms_current;
            uint8_t bms_soc;
            uint8_t bms_fault_level;
            uint8_t bms_fault_code;

            int8_t dip_angle_x;
            int8_t dip_angle_y;
            uint16_t dip_angle;

            motor_data_t left_motor;
            motor_data_t right_motor;
            motor_data_t rolling_brush_motor;

            uint8_t other_fault;
            uint8_t reserve_1;
        }data;
    }radio_tx_data_buf_t;
    #endif
#endif
#if (CHUANZHOU_PROTOCOL == 1)
typedef struct motor_data{
    int16_t speed;
    uint8_t dc_voltage;
    int8_t  dc_current;
    uint8_t control_status;
    uint8_t fault_code;
}motor_data_t;
typedef union radio_tx_data_buf{
	uint8_t buf[RADIO_TX_DATA_BUFF_NUMBER];
	struct{
        uint8_t reserve_0;
        uint8_t bms_voltage;
        int8_t  bms_current;
        uint8_t bms_soc;
        uint8_t bms_fault_level;
        uint8_t bms_fault_code;

        int8_t dip_angle_x;
        int8_t dip_angle_y;
        uint16_t dip_angle;

        motor_data_t left_motor;
        motor_data_t right_motor;
        motor_data_t rolling_brush_motor;

        uint8_t other_fault;
        uint8_t reserve_1;
	}data;
}radio_tx_data_buf_t;


typedef struct radio_data_byte
{
    uint8_t emorgency:1;  /*急停信号*/
    uint8_t mode_adjust:1;/*调试模式*/
    uint8_t reserve:6;    /*保留*/
}radio_data_byte_t;

typedef union radio_rx_data_buf{
    uint8_t buf[32];
    struct{
        uint8_t left_joystick_up_down;     /*左摇杆上下*/
        uint8_t left_joystick_left_right;  /*左摇杆左右*/
        uint8_t right_joystick_up_down;    /*右摇杆上下*/
        uint8_t right_joystick_left_right; /*右摇杆左右*/
        uint8_t reserve_0; 
        uint8_t reserve_1;
        uint8_t reserve_2;
        uint8_t left_right_key;
        uint8_t heart_beat;
        uint8_t reserve_3;
        radio_data_byte_t last_byte;
    }data;
}radio_rx_data_t;
extern radio_rx_data_t ut_radio_rx_data;
#endif
#endif /* __RADIO_CONFIG_H__ */
